package com.example.smartcanteen.controller;

import com.example.smartcanteen.model.Shop;
import com.example.smartcanteen.service.ShopService;
import com.example.smartcanteen.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/shop")
@CrossOrigin
public class ShopController {
    @Autowired
    private ShopService shopService;


    //商家注册 所需数据：String username；String password；String shopname；String phone；String address；String type；
    @PostMapping("/create")
    ResponseMessage create(Shop shop) {


        return shopService.create(shop);
    }


    //商家登录 所需数据：String username；String password；
    @PostMapping("/login")
    ResponseMessage login(String username,String password) {


        return shopService.login(username,password);
    }


    //查看全部商家（管理员适用）
    @GetMapping("/selectAll")
    ResponseMessage selectAll() {


        return shopService.selectAll();
    }


    //查看全部营业商家（学生适用）
    @GetMapping("/selectAllUp")
    ResponseMessage selectAllUp() {


        return shopService.selectAllUp();
    }


    //搜素指定商家
    @PostMapping("/selectById")
    ResponseMessage selectById(String shopID) {


        return shopService.selectById(shopID);
    }
}
